<template>
    <div>
        <!-- 列表 -->
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media" v-for="item in newslist" :key="item.id">
                <!-- <router-link to="/home/newslist"> -->
                <router-link :to="'/home/newslnfo/' + item.id">
                    <img class="mui-media-object mui-pull-left" :src="item.img_url">
                    <div class="mui-media-body">
                        <h3>{{item.title}}</h3>
                        <p class='mui-ellipsis'>
                            <span>发布时间：{{item.add_time | datemsg}}</span>
                            <span>点击次数：{{item.click}}</span>
                        </p>
                    </div>
                </router-link>
            </li>
        </ul>

    </div>
</template>

<script>
// 错误提示
import { Toast } from 'mint-ui';

export default {
    data() {
        return {
            newslist: []
        }
    },
    methods: {
       getnewslist(){
           this.$http.get('api/getnewslist').then(result => {
               if(result.body.status == 0){
                //    console.log(result.body.message);
                   this.newslist = result.body.message;
               }else{
                   Toast('获取新闻列表失败')
               }
           })
       } 
    },
    created() {
        this.getnewslist()
    },
}
</script>

<style lang="less" scoped>
    .mui-media-body{
        h3{
            font-size: 15px;
            font-weight: normal;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        p{
            display: flex;
            justify-content: space-between;
            span{
                font-size: 12px;
            }
        }
    }
</style>